package com.cnhis.cloudhealth.clinical.hosnurse.hosadviceprint.bo;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cnhis.cloudhealth.clinical.hosnurse.hosadviceprint.dao.HosAdvicePrintDao;
import com.cnhis.cloudhealth.commons.Mappers.ModelVo;
import com.cnhis.cloudhealth.commons.utils.Page;
import com.cnhis.cloudhealth.commons.utils.StaticKeys;

@Service
public class HosAdvicePrintBo {
  @Resource 
  private HosAdvicePrintDao hosAdvicePrintDao;
  
   public ModelVo requestBillsTotal(Map map,int currPage,int pageSize)throws Exception{
	   ModelVo mo = new ModelVo();
		Page pg = null;
		try {
			pg = hosAdvicePrintDao.requestBillsTotal(map, currPage, pageSize);
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}

		mo.setList(pg.getList());
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setTotal(pg.getTotalNumber());
		mo.setRows(pg.getList());
		return mo;
   }
	
	
	public ModelVo requestBillsDetail(Map map,int currPage,int pageSize)throws Exception{
		ModelVo mo = new ModelVo();
		Page pg = null;
		try {
			pg = hosAdvicePrintDao.requestBillsDetail(map, currPage, pageSize);
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}

		mo.setList(pg.getList());
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setTotal(pg.getTotalNumber());
		mo.setRows(pg.getList());

		return mo;
		
	}
	public ModelVo finishedPrintRows(Map map)throws Exception{
		ModelVo mo = new ModelVo();
		List list = null;
		try {
			list = hosAdvicePrintDao.finishedPrintRows(map);
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}

		mo.setList(list);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(list);
		return mo;
	}
	public ModelVo finishedPrintPages(Map map)throws Exception{
		ModelVo mo = new ModelVo();
		List list = null;
		try {
			list = hosAdvicePrintDao.finishedPrintPages(map);
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}

		mo.setList(list);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(list);
		return mo;
	}
	public ModelVo printMaxRows(Map map)throws Exception{
		ModelVo mo = new ModelVo();
		List list = null;
		try {
			list = hosAdvicePrintDao.printMaxRows(map);
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}

		mo.setList(list);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(list);
		return mo;
	}
	public ModelVo unPrintRows(Map map)throws Exception{
		ModelVo mo = new ModelVo();
		List list = null;
		try {
			map.put("OneRow", hosAdvicePrintDao.getOneRow());
			list = hosAdvicePrintDao.unPrintRows(map);
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}

		mo.setList(list);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(list);
		return mo;
	}

	public ModelVo getCheckResult(Map map)throws Exception{
		ModelVo mo = new ModelVo();
		List list = null;
		try {
			list = hosAdvicePrintDao.getCheckResult(map);
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}

		mo.setList(list);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(list);
		return mo;
	}

}
